package com.xuelang.pipeline.worker.client.pod;

import com.xuelang.pipeline.worker.client.common.feign.PodServiceFallbackImpl;
import com.xuelang.pipeline.worker.client.common.result.ApiResult;
import com.xuelang.pipeline.worker.client.pod.config.PodFeignConfig;
import com.xuelang.pipeline.worker.client.pod.dto.PodQueryDTO;
import com.xuelang.pipeline.worker.client.pod.dto.QueryDTO;
import io.kubernetes.client.openapi.models.V1PodList;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import jakarta.validation.Valid;

/**
 * @author liuyuan.ly
 * @since 2024/5/29 9:48
 */
@FeignClient(name = "pod-service", url = "${feign.rpc.workerService}",
        fallback = PodServiceFallbackImpl.class,
        configuration = PodFeignConfig.class)
public interface IPodService {

    @PostMapping(value = "/get/pod/list", produces = "application/json;charset=utf-8")
    ApiResult<V1PodList> getPodList(@RequestBody @Valid QueryDTO queryDTO);


    @PostMapping(value = "/get/pod/log", produces = "application/json;charset=utf-8")
    ApiResult<String> getPodLog(@RequestBody @Valid PodQueryDTO queryDTO);

    @PostMapping(value = "/get/pod/log/stream", produces = "application/octet-stream")
    ResponseEntity<StreamingResponseBody> streamPodLog(@RequestBody @Valid PodQueryDTO queryDTO);
}
